package com.xuanwu.utils;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class FileUtil {

	public static Map<String, Object> read(String path) {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			System.out.println(path);
			InputStream in = FileUtil.class.getClassLoader().getResourceAsStream(path);
			BufferedReader reader = new BufferedReader(new InputStreamReader(in));
			String title = reader.readLine();
			String value = null;
			List<String> data = new LinkedList<String>();
			while ((value = reader.readLine()) != null) {
				data.add(value);
			}
			map.put("title", title);
			map.put("data", data);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return map;
	}

}
